import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TemplateMarketVO, TemplateMarketForm, TemplateMarketQuery } from '@/api/templateMarket/types';

/**
 * 查询模板市场列表
 * @param query
 * @returns {*}
 */

export const listTemplateMarket = (query?: TemplateMarketQuery): AxiosPromise<TemplateMarketVO[]> => {
  return request({
    url: '/company/templateMarket/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询模板市场详细
 * @param id
 */
export const getTemplateMarket = (id: string | number): AxiosPromise<TemplateMarketVO> => {
  return request({
    url: '/admin/templateMarket/' + id,
    method: 'get'
  });
};

/**
 * 新增模板市场
 * @param data
 */
export const addTemplateMarket = (data: TemplateMarketForm) => {
  return request({
    url: '/admin/templateMarket',
    method: 'post',
    data: data
  });
};

/**
 * 修改模板市场
 * @param data
 */
export const updateTemplateMarket = (data: TemplateMarketForm) => {
  return request({
    url: '/admin/templateMarket',
    method: 'put',
    data: data
  });
};

/**
 * 删除模板市场
 * @param id
 */
export const delTemplateMarket = (id: string | number | Array<string | number>) => {
  return request({
    url: '/admin/templateMarket/' + id,
    method: 'delete'
  });
};

/**
 * 查询我的收藏模板列表
 * @param query
 * @returns {*}
 */
export const myCollectTemplateList = (query) => {
  return request({
    url: '/company/collectTemplate/myCollectTemplateList',
    method: 'get',
    params: query
  });
};

/**
 * 收藏模板
 * @param data
 */
export const collectTemplate = (data) => {
  return request({
    url: '/company/collectTemplate',
    method: 'post',
    data: data
  });
};

/**
 * 取消收藏模板
 * @param ids
 */
export const cancelCollectTemplate = (ids) => {
  return request({
    url: '/company/collectTemplate/' + ids,
    method: 'delete'
  });
};
